package cn.itcast.haa.tool;

import com.alibaba.cloud.ai.toolcalling.sinanews.SinaNewsService;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 新浪新闻查询工具
 *
 * @Author mr.wu
 * @Date 2025-11-7 15:31
 */
@Component
public class SinaTool {

    @Autowired
    private SinaNewsService sinaNewsService;

    @Tool(description = "查询新浪新闻热门新闻")
    public List<SinaNewsService.HotEvent> getSinaNews(){
        SinaNewsService.Response response = sinaNewsService.apply(new SinaNewsService.Request());
        List<SinaNewsService.HotEvent> hotEventList = response.events();
        return hotEventList;
    }
}
